package com.neusoft.a312cxy.android18cxy.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.neusoft.a312cxy.android18cxy.R;
import com.neusoft.a312cxy.android18cxy.bean.MyShaituBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Young on 2017/11/2.
 */

public class myshaituAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List<MyShaituBean.ShaituBean> mDataList1;
    private LayoutInflater mLayoutInflater;


    public myshaituAdapter(Context mContext, List<MyShaituBean.ShaituBean> mDataList) {
        this.mContext = mContext;
        this.mDataList1 = mDataList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public  myshaituAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mLayoutInflater.inflate(R.layout.cardview_myshaitu, parent, false);
        return new myshaituAdapter.ViewHolder(v);


    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        final MyShaituBean.ShaituBean entity =  mDataList1.get(position);
        if (null == entity)
            return;
        myshaituAdapter.ViewHolder viewHolder = (myshaituAdapter.ViewHolder) holder;
        viewHolder.title.setText(entity.getTitle());
        viewHolder.update_time.setText(entity.getUpdate_time());
        if(!entity.getThumb0().isEmpty())
        {
            Picasso.with(mContext).load("http://172.24.10.175/workout/Uploads/"+entity.getThumb0()).into(viewHolder.thumb0);
        }
        else
        {
            viewHolder.thumb0.setImageResource(R.drawable.ic_club);
        }




    }

    @Override
    public int getItemCount() {
        return mDataList1.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
         ImageView thumb0;
        TextView update_time, title;




        public ViewHolder(View itemView) {
            super(itemView);
            thumb0= (ImageView) itemView.findViewById(R.id.photo);
            title = (TextView) itemView.findViewById(R.id.realname);
            update_time= (TextView) itemView.findViewById(R.id.lastlogtime);
           // type=(TextView) itemView.findViewById( R.id.type);
           // orderid=(TextView) itemView.findViewById( R.id.id);



        }
    }
}